<?php
abstract class Pageley_Query_Condition_Single implements Pageley_Query_Condition {
	private $propertyName;
	private $value;
	private $values;
	private $sql;
	private $index;
	private $query;

	public function __construct($propertyName, $value) {
		$this->propertyName = $propertyName;
		$this->value = $value;
	}

	public abstract function getOperator();

	public function getPropertyName() {
		return $this->propertyName;
	}

	public function getValues() {
		if($this->values === null) {
			$this->values = new Pageley_Util_ArrayMap();
			$this->values->put($this->getKey(), $this->getValue());
		}
		return $this->values;
	}

	public function getValue() {
		return $this->value;
	}

	public function getKey() {
		return $this->getPropertyName() . $this->getIndex();
	}

	private function getIndex() {
		if($this->index === null) {
			$this->index = $this->query->getNextIndex($this->propertyName);
		}
		return $this->index;
	}
	
	public function setQuery($query) {
		$this->query = $query;
	}

	public function __toString() {
		return $this->getKey() . " " . $this->getOperator() . " " . $this->getValue();
	}
}